package com.sharkburner.aeris.ui.module.site.model;

import java.io.Serializable;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.sharkburner.aeris.service.source.SourceService;
import com.sharkburner.aeris.ui.module.site.bean.SourceBean;
import com.vaadin.ui.AbstractLayout;

@Component
public class AddSiteModel implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private AbstractLayout layout;
	@Autowired
	private transient SourceService sourceSerice;
	@Autowired
	private SourceBean sourceBean;

	public void setLayout(AbstractLayout layout) {
		this.layout = layout;
	}

	public boolean addSource(String sourceName) {
		sourceBean.setName(sourceName);
		sourceSerice.save(sourceBean);
		layout.getWindow().showNotification("Source" + sourceName + " added");
		return true;
	}
}
